package jehc.djshi.common.thread;

import jehc.djshi.common.base.BaseResult;
import jehc.djshi.common.entity.OperateBusinessLogsEntity;
import jehc.djshi.common.util.RestTemplateUtil;
import jehc.djshi.common.util.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
/**
 * @Desc 异常日志
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Slf4j
public class OperateBusinessLogsThread implements Runnable{
	private OperateBusinessLogsEntity operateBusinessLogsEntity;
	private HttpServletRequest request;

	public OperateBusinessLogsThread(OperateBusinessLogsEntity operateBusinessLogsEntity){
		this.operateBusinessLogsEntity = operateBusinessLogsEntity;
	}

	public OperateBusinessLogsThread(OperateBusinessLogsEntity operateBusinessLogsEntity,HttpServletRequest request){
		this.operateBusinessLogsEntity = operateBusinessLogsEntity;
		this.request = request;
	}

	@Autowired
	RestTemplateUtil restTemplateUtil;
	public void run(){
		try {
			putOperateBusinessLogs(request);
		} catch (Exception e) {
			log.info("记录日志失败:"+operateBusinessLogsEntity.toString()+"，异常信息：{}",e);
		}
    }

	/**
	 * 添加平台业务操作日志通用 采用put方法目的不走事务控制
	 */
	public void putOperateBusinessLogs(HttpServletRequest request){
//		try {
//			log.info("记录日志开始");
//			restTemplateUtil.post(restTemplateUtil.restLogUrl() + "/xtOperateBusinessLogs/add", BaseResult.class, this.operateBusinessLogsEntity, request);
//			log.info("记录日志结束");
//		} catch (Exception e) {
//			log.info("记录日志失败:"+operateBusinessLogsEntity.toString()+"，异常信息：{}",e);
//		}
	}
}
